package edu.gatech.cc.hwa.server.features;

import edu.gatech.cc.hwa.server.Profile;

public class OperatingSystemFeature extends Feature {
	
	protected static final int ANY = -1;
	protected static final int WINDOWS = 0;
	protected static final int MAC = 1;
	protected static final int UNIX_LIKE = 2;
	protected static final int MOBILE = 3;
	protected static final int OTHER = 4;
	
	private final String platform;
	
	public OperatingSystemFeature(String platform){
		super(platform);
		this.platform = platform;
	}

	@Override
	public boolean matchesProfile(Profile profile) {
		int profileOs = profile.getOperatingSystem();
		return (profileOs == ANY) || (profileOs == mapToId());
	}
	
	public int mapToId() {
		return mapToId(platform);
	}

	public static int mapToId(String platform) {
		if(platform.equals("Win32") || platform.equals("Win64"))
			return WINDOWS;
		else if(platform.equals("MacIntel"))
			return MAC;
		else if(platform.equals("Linux x86_64") || platform.equals("Linux x86_32"))
			return UNIX_LIKE;
		else if(platform.equals("Android") || platform.equals("iPhone"))
			return MOBILE;
		return OTHER;
	}
}
